<?php


namespace Hilaoyu\LaravelPrivateApi;



trait PrivateApiControllerHelperTrait
{
    /**
     * @return EnAes
     */
    protected function getEncryptor(){
        return \request()->route('_encryptor');
    }


    /**
     * @return array | string
     */
    protected function getRequestData($key='',$default=null){
        $key = trim($key);
        $data=  \request()->route('_data');

        return $key ? data_get($data,$key,$default) : $data ;
    }


    protected function responseException(\Exception $exception){
        return comResponse()
            ->failed('系统错误')
            ->withErrors(UtilStr::toUtf8($exception->getMessage()))
            ->json();
    }





}
